// all_test02.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "all_test02.h"
#include <stdio.h>
#define ALLEGRO_USE_CONSOLE
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>


#include "TankFactory.h"
#include "Tank.h"

const unsigned int kWidth = 800;
const unsigned int kHeight = 600;

int main(int argc, char **argv)
{
   ALLEGRO_DISPLAY *display = NULL;
 
   if(!al_init()) {
      fprintf(stderr, "failed to initialize allegro!\n");
      return -1;
   }

   al_init_primitives_addon();
 
   // Display setup
   al_set_new_display_flags( ALLEGRO_WINDOWED );
   display = al_create_display(kWidth, kHeight);
   if(!display) {
      fprintf(stderr, "failed to create display!\n");
      return -1;
   }
 
   al_clear_to_color(al_map_rgb(0,0,0));
    
   // ==========================
   _Tank tank( TankFactory::BuildBase1Tank() );

   BaseComponent::point centerPoint = {400, 300};
    
    tank->MoveTo( centerPoint );
	
	for ( float i = 0.0, j = 0.0; i < 7.0; i += 0.017, j += 0.02 ) {
		al_clear_to_color(al_map_rgb(0,0,0));
		tank->RotateTo( i );
		tank->RotateTurretTo( 0, j );
		tank->Draw();
		al_flip_display();
		al_rest(0.05);
	}
    
    
   // ==========================
 
   al_flip_display();
 
   al_rest(2.0);
 
   al_destroy_display(display);
 
   return 0;
}